<?php include "include/function_library.php"; ?>
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>

<?php include "html/header.html"; ?>

</head>
<body class="tcuk home">

	<div id="wp">
	
		<?php  include "html/menu.html"; ?>
		
		<!-- CONTENT STARTS-->
		<div id="ct"> 	
			
			<?php 
			/* SIGN UP FORM PHP PART */
			if(post("nm_submit")) {
				$nm_name 		= post("nm_name");
				$nm_surname 	= post("nm_surname");
				$nm_email 		= post("nm_email");
				$nm_pass 		= post("nm_pass");
				$nm_birthdate 	= post("nm_birthdate");
				$nm_interest 	= post("nm_interest");

				$link = connect();
				$query = "INSERT INTO user (name, surname, email, password, birthdate) VALUES ('$nm_name', '$nm_surname', '$nm_email', '$nm_pass', '$nm_birthdate')";
				$result = mysql_query($query, $link);
				
				if($result) {
					$last_added_user_id = mysql_insert_id();
					$query = "INSERT INTO customer (id, interests) VALUES ('$last_added_user_id', '$nm_interest')";
					$result = mysql_query($query, $link);
				}
				mysql_close($link);
				
				if($result) {
					echo "<div class='alert success'>Signed Up Successfully! You can <a href='login_form.php'>login</a>.</div>";
				} else {
					echo "<div class='alert error'>Error! Could Not Register! There is(are) error(s) in the form!</div>";
				}
			}
			?>
			
			<!-- SIGN UP FORM HTML PART -->
			<form action="<?php echo curPageURL(); ?>" method="post">
			<ul id="signup_form" style="width: 50%; margin-left: auto; margin-right: auto; margin-top: 30px; list-style: none;">
				<li style="border: none;">
					<label>Name </label>
					<input type="text" id="nm_name" name="nm_name" value="" placeholder="Your Name.." style="width: 250px;"/>
				</li>
				<li>
					<label>Surname </label>
					<input type="text" id="nm_surname" name="nm_surname" value="" placeholder="Your Surname.." style="width: 250px;"/>
				</li>
				<li>
					<label>Email </label>
					<input type="email" id="nm_email" name="nm_email" value="" placeholder="Your Email Address.." style="width: 250px;"/>
				</li>
				<li>
					<label>Password </label>
					<input type="password" id="nm_pass" name="nm_pass" value="" placeholder="Your Password.." style="width: 250px;"/>
				</li>
				<li>
					<label>Birth Date </label>
					<input type="date" id="nm_birthdate" name="nm_birthdate" value="" placeholder="Your Birth Date.." style="width: 250px;"/>
				</li>
				<li>
					<label>Interests </label>
					<textarea rows="10" id="nm_interest" name="nm_interest" placeholder="Tell About Your Interests.." style="width: 250px;"></textarea>
				</li>
				<li>
					<input type="submit" id="nm_submit" name="nm_submit" value="Sign Up" style="width: 90px; height:30px; margin-left: 80px;"/>
				</li>
			</ul>
			</form>
		
		</div> 	
		<!-- CONTENT ENDS-->		
		
		<?php include "html/footer.html"; ?>
		
	</div>
	
</body>
</html>